package hshsm.managers;


import hsh.util.Status;
import hshs.process.Process;
import hshs.process.Program;

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;

public class Scheduler {

	
	private Queue<Process> queueReadyProcess;
	private Queue<Process> queueFinishedProcess;
	private int nextPid;
	
	
	public Scheduler() {
		
		this.queueReadyProcess = new PriorityQueue<Process>();
		this.queueFinishedProcess = new ConcurrentLinkedQueue<Process>();
		this.nextPid = 0;
	}

	public void addNewProcess(Program program) {
		
		Process process = new Process(program,this.nextPid);
		this.nextPid++;
		process.setStatus(Status.READY);
		System.out.println("inseriu");
		this.queueReadyProcess.add(process);
	}

	public Process nextProcess() {
		
		return this.queueReadyProcess.poll();
	}

	public void addReadyProcess(Process process) {
		
		this.queueReadyProcess.add(process);
	}

	public void addFinishedProcess(Process process) {
		this.queueFinishedProcess.add(process);
		
	}
	
	
	
}
